<?php
//清空表  truncate category2 主键归0
require 'db.php';
require 'function.php';
$action = isset($_GET['a'])?$_GET['a']:'index';
switch ($action) {
	case 'index':
		$data = select("select * from category2 order by concat(path,'-',id) asc");
		$data = categoryTree($data);
		// p($data);exit;
		require 'view/index.html';
		break;
	case 'add':
		require 'view/add.html';
		break;	
	case 'doadd':
		execute("insert into category2 (cname,path) 
			value('{$_POST['cname']}','{$_POST['path']}')");
		header('location:?a=index');
	default:
		
		break;
}